  #pragma once
#include "HashTable.h"
namespace unmap {

	template<class K,class V, class Hash = HashFunc<K>>
	class unorder_map
	{
		struct KeyOfMap {
			const K& operator()(const pair<const K,V>& key)
			{
				return key.first;
			}
		};
	public:
		typedef typename bucketHash::HashBucket<K, pair<const K, V>, Hash, KeyOfMap>::iterator iterator;

		V& operator[](const K& key)
		{
			pair<iterator, bool> ret = _ht.insert(make_pair(key, V()));
			return ret.first->second;
		
		}
		iterator begin()
		{
			return _ht.begin();
		}
		iterator end()
		{
			return _ht.end();
		}

		pair<iterator,bool> insert(const pair< K, V>& key)
		{
			return _ht.insert(key);
		}
	private:
		bucketHash::HashBucket<K, pair<const K,V>, Hash, KeyOfMap> _ht;

	};


	void Teststring()
	{
		string arr[] = { "苹果","香蕉","草莓","菠萝","苹果","香蕉","草莓","苹果","香蕉","草莓","苹果","香蕉","苹果","苹果" };
		unorder_map<string, int> HString;

		for (auto e : arr)
		{
			HString[e]++;
		}
		for (auto e : HString)
		{
			cout << e.first << "  :" << e.second << "  ";
		}
	}


}